home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 177 / pascal / getkey.doc < prev    next >
Encoding:
Text File  |  1987-09-16  |  2.6 KB  |  83 lines

  1.  
  2.              Intelligent Get_Key function for Personal Pascal
  3.  
  4.                   Written by Keith Ledbetter  6-Sept-87
  5.              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6.  
  7.  
  8.  
  9.   This Get_Key routine is a very handy routine for those of you who write TOS
  10. programs with Personal Pascal.  Have you ever been overwhelmed by all of the
  11. various keypresses that can be generated with an Atari ST keyboard?  Not to
  12. mention the fact that if you do want to process any Function keys, then you
  13. have to read the keypress as a Long_Integer and go from there.
  14.  
  15.  
  16.   This Get_Key routine solves this problem by returning everything as a CHAR
  17. value.  What it does is to return values in the high range (that couldn't
  18. be entered from the keyboard anyway).  This makes it very simple for you to
  19. process function keys from within your pascal program.
  20.  
  21.  
  22.   Any function key pressed will be returned as a CHAR value ranging from
  23. 201 through 235.  Any 'normal' (ie: 'a', 'Z', etc) will be returned normally.
  24. From your pascal program, just declare Get_Key as follows:
  25.  
  26.  
  27.  Function Get_Key: Char;       External;
  28.  
  29.  
  30.   Then, just LINK getkey.o along with your program's .o file.
  31.  
  32.  
  33.   Get_Key will return any non-function key just as normal.  The SPECIAL values
  34. returned from Get_Key are as follows:
  35.  
  36.  
  37.          Keypress           Value
  38.          --------           -----
  39.          F1  - F10          201 - 210
  40.          F11 - F20          211 - 220     ( these are SHIFT F1 - F10 )
  41.          left arrow         221
  42.          right arrow        222
  43.          ^left arrow        223
  44.          ^right arrow       224
  45.          delete             225
  46.          insert             226
  47.          undo               227
  48.          help               228
  49.          clear/home         229
  50.          shift clear        230
  51.          shift insert       231
  52.          shift left arrow   232
  53.          shift up arrow     233
  54.          shift right arrow  234
  55.          shift down arrow   235
  56.  
  57.  
  58.  This makes it very easy to process keypresses with the following type
  59. of code:
  60.  
  61.  Var Ch: Char;
  62.  
  63.  Begin
  64.    Repeat
  65.      Ch := Get_Key;
  66.      Case Ord (Ch) of
  67.         201: Writeln ('You hit the F1 key!');
  68.         228: Writeln ('You hit the HELP key!');
  69.        Else: Writeln ('You hit the ', Ch, ' key');
  70.      End;
  71.    Until whatever;
  72.  
  73.  
  74.  
  75.  The assembler source code to GET_KEY is included in the ARC file, but you DO
  76. NOT need to do anything with it.  It's just there in case someone would like
  77. to add more keys to the table.  If you do, just make SURE that you keep the
  78. '0,0' entry at the end of the table.
  79.  
  80.  
  81.                         Keith Ledbetter
  82.                         CIS #76701,124
  83.